<?php
// Load Header
$this->pageTitle = $top_news[0]['Category']['name'];

// Load Css
echo $this->Html->css('news_page');
echo $this->Html->css('news_list_page');
echo $this->Html->css('edit_news');

// Load Javascript
echo $this->Html->script('jquery.scrollfollow');
echo $this->Html->script('custom.list.news');
?>
<script language='javascript'>
$(document).ready(function() {
	var ajax_section = '#ajax_news';
	var content_section = '#news_list';
	var paging_section = '#news_pagination';
	
	setAjaxPaging(ajax_section, content_section, paging_section);
	
});

function setAjaxPaging(ajax_section, content_section, paging_section) {
	$('div'+paging_section+' a').click(function() {
		var link = $(this).attr('href');
		$('div'+content_section).html("<?php __("Vui lòng đợi ...");?>");
		$.ajax({
			url: link,
			success: function(responseContent) {
				$('div'+ajax_section).html(responseContent);
				setAjaxPaging(ajax_section, content_section, paging_section);
			}
		});
		return false;
	});
}
</script>
<div id="content_container">
			<div id="content">
				<h2 class="title"><a class="fisrt" href="<?php echo $html->url(array('plugin' => 'news', 'controller' => 'news', 'action' => 'index'));?>">Tin tức - Sự kiện</a><a class="finish" href="<?php echo $html->url(array('plugin' => 'news', 'controller' => 'sections', 'action' => 'index', $top_news[0]['Category']['alias']));?>"><?php echo $top_news[0]['Category']['name']?></a></h2>
				<div class="content_news content_news_it">
					<ul class="block_news">
						<?php foreach($top_news as $item):
						$image = $item[$models['Page']['name']]['image'];
						if ($image != "") {
							$ext = strrchr($image, ".");
							$pos = strrpos($image, ".");
							$filename = substr($image,0,$pos);
							$image = $filename."_thumbnail".$ext;
						}
						?>
						<li>
							<a href="<?php echo $html->url(array('plugin' => 'news', 'controller' => 'news', 'action' => 'view', $item[$models['Page']['name']]['alias']))?>" class="title"><?php echo $item[$models['Page']['name']]['title'];?></a>
							<table class="icon_cell">
								<tr>
									<td>
										<img src="<?php echo $html->url('/'.$configs[$models['Page']['name']]['image']['uri'].$image);?>"/>
									</td>
								</tr>
							</table>
							<p class="text_news">
							<?php echo $item[$models['Page']['name']]['description'];?>
							</p>
							<a class="read_more" href="<?php echo $html->url(array('plugin' => 'news', 'controller' => 'news', 'action' => 'view', $item[$models['Page']['name']]['alias']))?>">Xem tiếp</a>	
						</li>
						<?php endforeach;?>
					</ul>
					<ul class="list_other_news">
						<h2 class="title_other_news">Tin liên quan:</h2>
						<?php echo $this->element('section_other_news', array('plugin' => 'news'));?>
					</ul>
				</div>
			</div>
		</div>